package net.melon.product.inst.struts2;

import javax.annotation.Resource;

import net.esj.basic.core.engine.config.MelonConfig;
import net.esj.basic.core.utils.PropertiesInfo;
import net.esj.basic.utils.StringUtils;
import net.esj.basic.view.AbstractPluginPageAction;
import net.melon.product.inst.service.BrandService;
import net.melon.product.pojo.ProductBrand;
import net.melon.uploader.Uploader;

public class BrandAction extends AbstractPluginPageAction<ProductBrand, ProductBrand>{

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3300484845134961861L;
	
	@Resource
	private BrandService brandService;
	
	@Override
	protected void doQueryPage() {
		pagination.getQueryBuilder().eq("state", 1);
		super.doQueryPage();
	}
	@Override
	protected void doGetEntity() {
		entity = defaultService.get(Long.valueOf(id), ProductBrand.class);
	}
	
	@Override
	protected void doAdd() throws Exception {
		brandService.addBrand(entity);
	}

	@Override
	protected void doDelete() throws Exception {
		brandService.deleteBrand(Long.valueOf(id));
	}
	
	@Override
	protected void doUpdate() throws Exception {
		brandService.updateBrand(entity);
	}
	public ProductBrand getEntity(){
		return entity;
	}
	
	public void setEntity(ProductBrand entity){
		this.entity = entity;
	}
	
	public String getDownloadUrl(){
		return Uploader.getDownUrl(ProductBrand.ICON_SUB_DIR);
	}
}
